package Code.Day2_20240919.com.dx.day02;

import java.sql.Array;
import java.util.*;

/**
 * @ClassName ArrayTest01
 * @Description 数组
 * @Author 12994
 * @Date 2024/9/19 22:15
 * @Version 1.0
 **/
public class ArrayTest01 {
    public static void main(String[] args) {
        // 使用数组计算5名学员的平均分

        double[] list = new double[5];
        Scanner input = new Scanner(System.in);
        for (int i = 0; i < list.length; i++) {
            System.out.printf("请输入第%d名学员的成绩: ", i + 1);
            list[i] = input.nextDouble();
        }
        System.out.print("平均分是: ");
        System.out.println(Arrays.stream(list).average().getAsDouble());

        // for each
        for (double score : list) {
            System.out.print(score + "\t");
        }

    }
}
